Skip to content

Conversation

AbduazizZiyodov
Copy link
Member

@AbduazizZiyodov AbduazizZiyodov commented Sep 23, 2025

Closes #3326 by deprecating RaisesGroup where pytest alternative recommended from now on.

@AbduazizZiyodov
Copy link
Member Author

AbduazizZiyodov commented Sep 23, 2025

I've got couple of questions.

  • Version should be 0.31.0 or 0.32.0 ?
  • Is that OK to warn about deprecation during __init__ or do I have to move this into __enter__ ?
  • What can we do about the existing tests that uses RaisesGroup, can just "replace" them with pytest alternative ?
image

(I'll include newsfragment later)

Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.30300%. Comparing base (84fbcb7) to head (5be7c99).

❌ Your project check has failed because the head coverage (94.30300%) is below the target coverage (100.00000%). You can increase the head coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (84fbcb7) and HEAD (5be7c99). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (84fbcb7) HEAD (5be7c99)
3.11 5 4
Windows 15 14
3.12 5 4
Additional details and impacted files
@@                 Coverage Diff                  @@
##                 main       #3337         +/-   ##
====================================================
- Coverage   100.00000%   94.30300%   -5.69701%     
====================================================
  Files             125         125                 
  Lines           19586       19835        +249     
  Branches         1342        1384         +42     
====================================================
- Hits            19586       18705        -881     
- Misses              0        1102       +1102     
- Partials            0          28         +28     
Files with missing lines Coverage Δ
src/trio/testing/_raises_group.py 29.01408% <100.00000%> (-70.98592%) ⬇️

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@A5rocks
Copy link
Contributor

A5rocks commented Sep 23, 2025

I've got couple of questions.

  • version should be the next Trio version. Since we're including a deprecation, this is a "minor" change, it's 0.32.0.
  • personally I think this should warn on attribute access! See _deprecate.deprecate_attributes. This way, someone even just going trio.RaisesGroup would get the warning without having to initialize it
  • yeah. I think the idiomatic replacement is pytest.raises_group? (Maybe the deprecation should link that instead of the class)

@AbduazizZiyodov
Copy link
Member Author

@A5rocks

personally I think this should warn on attribute access! See _deprecate.deprecate_attributes. This way, someone even just going trio.RaisesGroup would get the warning without having to initialize it

Makes sense. However even if I deprecate it on trio/__init__.py like this:

_deprecate.deprecate_attributes(
    __name__,
    {
        "RaisesGroup": _deprecate.DeprecatedAttribute(
            "RaisesGroup",
            version="0.32.0",
            issue=3326,
            instead="See https://docs.pytest.org/en/stable/reference/reference.html#pytest.RaisesGroup",
        )
    },
)

On trio.testing.RaisesGroup or just using RaisesGroup (via from trio.testing import) won't show any warnings. I guess we're trying to warn on even occurrence of RaisesGroup (even tried on testing/__init__.py). Am I missing something ? Thanks.

@A5rocks
Copy link
Contributor

A5rocks commented Sep 23, 2025

I think the deprecation should go in trio.testing?

I'm probably misunderstanding what you're saying cause it sounds like you tried that...

@A5rocks
Copy link
Contributor

A5rocks commented Sep 23, 2025

Note that this is how the usage looks like (it's a bit complicated because you need the actual underlying object, but under a different name)

deprecate_attributes(__name__, {
    "RaisesGroup": DeprecatedAttribute(_RaisesGroup, "0.32.0", ...)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace trio.testing.RaisesGroup with pytest.RaisesGroup
2 participants